package com.yiyuan.system.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.yiyuan.common.base.BaseDao;
import com.yiyuan.system.dao.IRolePriDao;
import com.yiyuan.system.model.RolePri;

@Repository("rolePriDao")
public class RolePriDaoHbImpl extends BaseDao implements IRolePriDao {
	public void add(RolePri rolePri) {
		this.getHibernateTemplate().save(rolePri);
	}

	@SuppressWarnings("unchecked")
	public List<RolePri> findListByPriId(Integer priId) {
		Session session = this.getSession();
		Query query = session.createQuery("from RolePri where priId=:priId");
		query.setInteger("priId", priId);
		List<RolePri> list = query.list();
		return list;
	}

	@SuppressWarnings("unchecked")
	public List<RolePri> findListByRoleId(Integer roleId) {
		Session session = this.getSession();
		Query query = session.createQuery("from RolePri where roleId=:roleId");
		query.setInteger("roleId", roleId);
		List<RolePri> list = query.list();
		return list;
	}

	public void delete(RolePri rolePri) {
		this.getHibernateTemplate().delete(rolePri);
	}
}
